<?php
use  yii\helpers\Url;
use  yii\helpers\Html;
$company = \backend\modules\models\setting\Menu::findOne(['name'=>'公司新闻']);
$company = $company->getLimitContent(3);

$basic = \backend\modules\models\setting\Menu::findOne(['name'=>'基层动态']);
$basic = $basic->getLimitContent(3);

$notice = \backend\modules\models\setting\Menu::findOne(['name'=>'通知公告']);
$notice = $notice->getLimitContent(3);

$bid = \backend\modules\models\setting\Menu::findOne(['name'=>'招标公告']);
$bid = $bid->getLimitContent(3);

$main    = \backend\modules\models\setting\Menu::findOne(['name'=>'新闻中心','parent_id'=>0]);
?>
<div class="col-md-6 col-lg-5">
    <ul class="nav-new nav nav-pills mb-3" id="pills-tab" role="tablist">
        <li class="nav-item" role="presentation">
            <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">公司新闻</a>
        </li>
        <li class="nav-item" role="presentation">
            <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">基层动态</a>
        </li>
        <li class="nav-item" role="presentation">
            <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact" role="tab" aria-controls="pills-contact" aria-selected="false">通知公告</a>
        </li>
        <li class="nav-item" role="presentation">
            <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-tenders" role="tab" aria-controls="pills-contact" aria-selected="false">招标公告</a>
        </li>
        <li class="nav-item">
            <button type="button" class="btn btn-danger btn-more btn-more-news" data-id="4">
                <a href="<?= Url::to(['site/menu','menu_id'=>$main?$main->id:0])?>">更多</a>
            </button>
        </li>
    </ul>
    <div class="tab-content" id="pills-new-tabContent">
        <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
            <ul class="list-unstyled">
            <?php if ($company) {?>
                <?php foreach ($company as $one => $first): ?>
                    <li class="media mb-4 border a-href bg-light shadow-sm" data-id="<?= Html::encode($first->id)?>">
                        <img src="<?= Html::encode($first->image)?>" />
                        <a class="media-body p-3 overflow-hidden a-href" href="<?= Url::to(['site/content','content_id'=>$first->id])?>">
                            <h5 class="mt-0 mb-1 text-truncate text-nowrap">
                                <div class="news-name">
                                    <div class="text-truncate"><?= Html::encode($first->title)?></div>
                                    <div class="news-time"><?= Html::encode($first->create_time)?></div>
                                </div>
                            </h5>
                            <hr class="news-hr" />
                            <p><?= Html::encode($first->resume)?></p>
                        </a>
                    </li>
                <?php endforeach ?>
            <?php }?>
            </ul>
        </div>
        <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
            <ul class="list-unstyled">
                <?php if ($basic) {?>
                    <?php foreach ($basic as $one => $first): ?>
                        <li class="media mb-4 border a-href bg-light shadow-sm" data-id="<?= Html::encode($first->id)?>">
                            <img src="<?= Html::encode($first->image)?>" />
                            <a class="media-body p-3 overflow-hidden a-href" href="<?= Url::to(['site/content','content_id'=>$first->id])?>">
                                <h5 class="mt-0 mb-1 text-truncate text-nowrap">
                                    <div class="news-name">
                                        <div class="text-truncate"><?= Html::encode($first->title)?></div>
                                        <div class="news-time"><?= Html::encode($first->create_time)?></div>
                                    </div>
                                </h5>
                                <hr class="news-hr" />
                                <p><?= Html::encode($first->resume)?></p>
                            </a>
                        </li>
                    <?php endforeach ?>
                <?php }?>
            </ul>
        </div>
        <div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
            <ul class="list-unstyled">
            <?php if ($notice) {?>
                <?php foreach ($notice as $one => $first): ?>
                    <li class="media mb-4 border a-href bg-light shadow-sm" data-id="<?= Html::encode($first->id)?>">
                        <img src="<?= Html::encode($first->image)?>" />
                        <a class="media-body p-3 overflow-hidden a-href" href="<?= Url::to(['site/content','content_id'=>$first->id])?>">
                            <h5 class="mt-0 mb-1 text-truncate text-nowrap">
                                <div class="news-name">
                                    <div class="text-truncate"><?= Html::encode($first->title)?></div>
                                    <div class="news-time"><?= Html::encode($first->create_time)?></div>
                                </div>
                            </h5>
                            <hr class="news-hr" />
                            <p><?= Html::encode($first->resume)?></p>
                        </a>
                    </li>
                <?php endforeach ?>
            <?php }?>
            </ul>
        </div>
        <div class="tab-pane fade" id="pills-tenders" role="tabpanel" aria-labelledby="pills-tenders-tab">
            <ul class="list-unstyled">
            <?php if ($bid) {?>
                <?php foreach ($bid as $one => $first): ?>
                    <li class="media mb-4 border a-href bg-light shadow-sm" data-id="<?= Html::encode($first->id)?>">
                        <img src="<?= Html::encode($first->image)?>" />
                        <a class="media-body p-3 overflow-hidden a-href" href="<?= Url::to(['site/content','content_id'=>$first->id])?>">
                            <h5 class="mt-0 mb-1 text-truncate text-nowrap">
                                <div class="news-name">
                                    <div class="text-truncate"><?= Html::encode($first->title)?></div>
                                    <div class="news-time"><?= Html::encode($first->create_time)?></div>
                                </div>
                            </h5>
                            <hr class="news-hr" />
                            <p><?= Html::encode($first->resume)?></p>
                        </a>
                    </li>
                <?php endforeach ?>
            <?php }?>
            </ul>
        </div>
    </div>
</div>